package com.nega.commons.model;

import com.nega.commons.enums.MessageCode;

import java.io.Serializable;

/**
 * @author Garc
 * @Date 2016年11月8日 下午3:34:00
 * @info 消息类
 * @snise
 **/
public class Message implements Serializable {

    /**
     *
     */
    private static final long        serialVersionUID = 1L;
    private              MessageCode code;
    private              String      content;
    private              Object      data;

    public Message() {

    }

    public Message(MessageCode code, String content) {
        this.code = code;
        this.content = content;
    }

    public Message(MessageCode code, String content, Object data) {
        this.code = code;
        this.content = content;
        this.data = data;
    }

    public static Message success(Object data) {
        return new Message(MessageCode.SUCCESS, "OK", data);
    }

    public static Message success(String content) {
        return new Message(MessageCode.SUCCESS, content);
    }

    public static Message success() {
        return new Message(MessageCode.SUCCESS, "OK");
    }

    /**
     * 参数不合法
     *
     * @param content
     * @return
     */
    public static Message illegalArgument(String content) {
        return new Message(MessageCode.ILLEGAL_ARGUMENT, content);
    }

    public static Message error(String content) {
        return new Message(MessageCode.FAILURE, content);
    }

    /**
     * 获取 code
     *
     * @return code
     */
    public MessageCode getCode() {
        return code;
    }

    /**
     * 设置 code
     *
     * @param code code
     */
    public void setCode(MessageCode code) {
        this.code = code;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    /**
     * 获取 data
     *
     * @return data
     */
    public Object getData() {
        return data;
    }

    /**
     * 设置 data
     *
     * @param data data
     */
    public void setData(Object data) {
        this.data = data;
    }

}